home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 9866 / 9866.xpi / modules / rss / 211.jsm < prev    next >
Encoding:
Text File  |  2009-09-25  |  1.5 KB  |  60 lines

  1. Components.utils.import("resource://samfind/rss/samfind_modrssutils.jsm");
  2.  
  3. var EXPORTED_SYMBOLS = ["samfindRSSGetLink", "samfindRSSGetTitle", "samfindRSSGetDate", "samfindRSSGetImage", "samfindRSSGetContent"];
  4.  
  5. function samfindRSSGetLink(websiteRssUrl, item)
  6. {
  7.     var content = (item.getElementsByTagName("description"))[0];
  8.     if (content)
  9.     {
  10.         content = content.textContent.replace(/&(lt|gt);/g, function(strMatch, p1){return (p1 == "lt") ? "<" : ">";});
  11.         var start = content.indexOf('<br/> <a href="');
  12.         if (start != -1)
  13.         {
  14.             start += 15;
  15.             var end = content.indexOf('">[link', start);
  16.             if (end != -1)
  17.             {
  18.                 return "javascript:samfind_rss.goTo('" + content.substring(start, end) + "');";
  19.             }
  20.         }
  21.     }
  22.     return null;
  23. }
  24.  
  25. function samfindRSSGetTitle(websiteRssUrl, item)
  26. {
  27.     return null;    
  28. }
  29.  
  30. function samfindRSSGetDate(websiteRssUrl, item)
  31. {
  32.     return null;
  33. }
  34.  
  35. function samfindRSSGetImage(websiteRssUrl, item)
  36. {
  37.     return " ";
  38. }
  39.  
  40. function samfindRSSGetContent(websiteRssUrl, item, title, link)
  41. {
  42.     var content = (item.getElementsByTagName("description"))[0];
  43.     if (!content)
  44.     {
  45.         return null;
  46.     }
  47.     var response = content.textContent.replace(/&(lt|gt);/g, function(strMatch, p1){return (p1 == "lt") ? "<" : ">";});
  48.     var start = response.indexOf('<br/> <a href="');
  49.     if (start != -1)
  50.     {
  51.         start += 5;
  52.         var end = response.indexOf('">[link]</a> ', start);
  53.         if (end != -1)
  54.         {
  55.             response = response.replace(response.substring(start, end + 12), "");
  56.         }
  57.     }
  58.     response = response.replace(/[\[\]]/g, "");
  59.     return response;
  60. }